﻿using System;
using EasySL.Share;
using System.Windows.Controls;
using System.Windows;

namespace EasySL.UI.Controls
{
    public partial class Drags : UserControl
    {
        public Drags()
        {
            InitializeComponent();

            this.dragElement.Drag();
            
            for (int i = 0; i < 20; i++)
            {
                TextBlock textBlock = new TextBlock();
                textBlock.Text = "Product_" + i.ToString();
                textBlock.Width = 65;
                this.listBox.Items.Add(textBlock);

                textBlock.Drag(textBlock.Text, null, (s, e) =>
                {
                    Point p = e.GetPosition(this.container);
                    if (p.X > 0 && p.X < this.container.Width && p.Y > 0 && p.Y < this.container.Height)
                        this.container.Children.Add(new TextBlock() { Text = (s as ContentControl).Content.ToString() });
                });
            }
        }
    }
}
